# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=mini-sendmail
_realname=mini_sendmail
pkgver=1.3.9
pkgrel=1
pkgdesc="Accept mail inside a chroot + wrapper for /bin/sh"
options="!check" # No testsuite
url="http://acme.com/software/mini_sendmail/"
arch="all"
license="BSD-2-Clause"
makedepends="$depends_dev"
subpackages="$pkgname-doc"
source="http://www.acme.com/software/$_realname/$_realname-$pkgver.tar.gz
	README.alpine
	LICENSE
	sh.c
	"

builddir="$srcdir"/$_realname-$pkgver

prepare() {
	default_prepare
	sed -e "s|^BINDIR.*|BINDIR = $pkgdir/var/lib/mini-sendmail|" \
		-e "s|^MANDIR.*|MANDIR = $pkgdir/usr/share/man|" \
		-e 's|cp mini_sendmail.8.*|cp mini_sendmail.8 $(MANDIR)/man8/|' \
		-i Makefile
}

build() {
	make
	cp "$srcdir"/sh.c ./
	gcc sh.c -o sh -static
}

package() {
	mkdir -p "$pkgdir"/var/lib/mini-sendmail
	mkdir -p "$pkgdir"/usr/share/man/man8
	mkdir -p "$pkgdir"/usr/share/doc/mini-sendmail
	make DESTDIR="$pkgdir" install
	install -Dm755 sh "$pkgdir"/var/lib/mini-sendmail/
	install -Dm644 "$srcdir"/README.alpine "$pkgdir"/usr/share/doc/mini-sendmail/
	install -Dm644 "$srcdir"/LICENSE "$pkgdir"/usr/share/doc/mini-sendmail/
}

sha512sums="b28c39d94b77acc27a8c9e99583904b43815936b2bf7e27b996685784ff1bc9882bdfc57822ddf62d3198f38ec3df0b766289115cb4e6c23abee93884d2d6bb9  mini_sendmail-1.3.9.tar.gz
bc6a389f20834956e86edbf033cd6b7a3b7df4a9c1a101a751179c4af444ca08a4cb0bb07dc3a01a3d72908f45059921db336814d9ac9f8eee61d61ce1b2e62f  README.alpine
315b63e597561d911541975160ef5b6158fa5421a638efb06bf5e7af72069484a057c332d590b9e8e72383b67e25f7393a81666f8b914d0c649f1572cf330077  LICENSE
7356bfb52c46ac79797fea620f7e39c4141c066006e1b72fbf247ea36268a8c89a04120c508c431e0ad152eec9891b2766e2782046e8ea370a1f8ea6699fa0ff  sh.c"
